#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#define MAX 128
#define SIZE_NUM sizeof(num) / sizeof(int)

int main(int argc, char const *argv[])
{
    srand(time(NULL));
    char buf[5][10] = {0};
    char name[MAX] = "l";
    char name2[MAX] = "s";
    char pow[MAX] = "1";
    char pow2[MAX] = "1";
    char my_name[MAX] = "";
    char my_pow[MAX] = "";
    int ide = 0;
    int i = 3;
    int num[5] = {0};
    int l = 3;
    int t = 5;
    int r = 0;
    int f = 0;
    int temp = 0;
    int n = 0;
    int h = 1;
    while (h)
    {
        i = 1;
        t = 5;
        printf("请选择你要进入的账户,学生账户输入8,老师账户输入7\n");
        scanf("%d", &ide);
        if (ide == 8)
        {

            while (i)
            {
                printf("您已进入学生账户，请输入用户名");

                scanf("%s", my_name);
                if (!strcmp(name2, my_name))
                {
                    printf("请输入%s密码", my_name);
                    scanf("%s", my_pow);
                    if (!strcmp(pow2, my_pow))
                    {
                        printf("恭喜你，登陆成功\n");
                        for (int j = 0; j < SIZE_NUM; j++)
                        {
                            printf("学生%d = %d\n", j, num[j]);
                        }
                        printf("输入1退回到选择用户界面,输入其他退出系统\n");
                        scanf("%d", &n);
                        if (n == 1)
                        {
                            t = 0;
                            i = 0;
                        }
                        else
                        {
                            t = 0;
                            i = 0;
                            h = 0;
                        }
                    }
                    else
                    {
                        printf("密码错误");
                        i--;
                    }
                }
                else
                {
                    printf("账号错误");
                    i--;
                }
            }
        }
        else if (ide == 7)
        {

            while (i)
            {
                printf("您已进入老师账户，请输入用户名\n");
                scanf("%s", my_name);
                if (!strcmp(name, my_name))
                {
                    printf("请输入%s密码", my_pow);
                    scanf("%s", my_pow);

                    if (!strcmp(pow, my_pow))
                    {
                        printf("恭喜你，登陆成功\n");
                        while (t)
                        {
                            printf("请输入学生成绩,输入-1完成输入,最多可输入五个学生\n");
                            scanf("%d", &r);
                            if (r == -1)
                            {
                                printf("\n");
                                break;
                            }
                            else
                            {
                                num[f] = r;
                                f++;
                                t--;
                            }
                        }
                        for (int j = 0; j < SIZE_NUM - 1; j++)
                        {

                            for (int k = 0; k < SIZE_NUM - j - 1; k++)
                            {
                                if (num[k] < num[k + 1])
                                {
                                    temp = num[k];
                                    num[k] = num[k + 1];
                                    num[k + 1] = temp;
                                }
                            }
                        }
                        printf("打印排序后的成绩\n");
                        for (int j = 0; j < SIZE_NUM; j++)
                        {
                            printf("学生%d = %d\n", j, num[j]);
                        }
                        printf("输入1退回到选择用户界面,输入其他退出系统\n");
                        scanf("%d", &n);
                        if (n == 1)
                        {
                            t = 0;
                            i = 0;
                        }
                        else
                        {
                            t = 0;
                            i = 0;
                            h = 0;
                        }
                    }
                    else
                    {
                        printf("密码错误\n");
                        i--;
                    }
                }
                else
                {
                    printf("账号错误\n");
                    i--;
                }
            }
        }
        else
        {
            printf("无此用户\n");
            break;
        }
    }

    return 0;
}
